/* ==========================================================================
   Atlas layout

   Extra styling for responsive layouts
========================================================================== */
@mixin layout-atlas-responsive() {
    $sidebar-icon-height: 52px;
    $sidebar-icon-width: 52px;

    .layout-atlas-responsive,
    .layout-atlas-responsive-default {
        @media (min-width: $screen-md) {
            --closed-sidebar-width: #{$navsidebar-width-closed};
            .mx-scrollcontainer-shrink:not(.mx-scrollcontainer-open) > .region-sidebar,
            .mx-scrollcontainer-push:not(.mx-scrollcontainer-open) > .region-sidebar,
            .mx-scrollcontainer-slide:not(.mx-scrollcontainer-open) > .region-sidebar {
                @if (not $use-modern-client) {
                    width: $navsidebar-width-closed !important;
                }

                .mx-scrollcontainer-wrapper .mx-navigationtree ul li {
                    &.mx-navigationtree-has-items a {
                        white-space: nowrap;
                    }

                    &.mx-navigationtree-has-items:hover > ul {
                        position: absolute;
                        z-index: 100;
                        top: 0;
                        bottom: 0;
                        left: $sidebar-icon-width;
                        display: block;
                        min-width: auto;
                        padding: $spacing-small 0;

                        & > li.mx-navigationtree-has-items:hover > ul {
                            left: 100%;
                        }
                    }

                    &.mx-navigationtree-collapsed,
                    &.mx-navigationtree-has-items {
                        ul {
                            display: none;
                        }
                    }
                }
            }

            .widget-sidebar:not(.widget-sidebar-expanded) {
                .mx-navigationtree ul li {
                    &.mx-navigationtree-has-items:hover {
                        ul {
                            position: absolute;
                            z-index: 100;
                            top: 0;
                            bottom: 0;
                            left: $sidebar-icon-width;
                            display: block;
                            overflow-y: auto;
                            min-width: auto;
                            padding: $spacing-small 0;
                        }
                    }

                    &.mx-navigationtree-collapsed,
                    &.mx-navigationtree-has-items {
                        ul {
                            display: none;
                        }
                    }
                }
            }
        }

        @if (not $use-modern-client) {
            .mx-scrollcontainer-slide {
                &:not(.mx-scrollcontainer-open) > .region-sidebar {
                    overflow: hidden;
                }

                &.mx-scrollcontainer-open > .region-sidebar {
                    width: $navsidebar-width-closed !important;

                    & > .mx-scrollcontainer-wrapper {
                        position: relative;
                    }
                }

                .region-sidebar > .mx-scrollcontainer-wrapper {
                    z-index: 2;
                    left: -$navsidebar-width-closed;
                    background-color: inherit;
                }
            }

            // Push aside for mobile
            @media (max-width: $screen-sm-max) {
                .mx-scrollcontainer-open:not(.mx-scrollcontainer-slide) {
                    width: 1100px;
                }

                .mx-scrollcontainer-slide .toggle-btn {
                    display: inline-block !important;
                }
            }
        }

        // Sidebar
        .region-sidebar {
            .toggle-btn {
                width: $sidebar-icon-width;
                border-color: transparent;
                border-radius: 0;
                background: transparent;
            }

            .mx-scrollcontainer-wrapper {
                .toggle-btn-wrapper {
                    display: flex;
                    padding: $spacing-small;
                    align-items: center;
                    min-height: calc(#{$topbar-minimalheight} + 4px);
                    background: $navsidebar-sub-bg;
                }

                .toggle-btn {
                    padding: $spacing-medium;

                    img {
                        width: 24px;
                        height: 24px;
                    }
                }

                .toggle-text {
                    color: #fff;
                    font-weight: bold;
                }

                .mx-navigationtree .navbar-inner > ul > li {
                    & > a {
                        height: $sidebar-icon-height;
                        padding: $spacing-small 0;
                        white-space: nowrap;
                        overflow: hidden;
                        // Glyph icon
                        .glyphicon,
                        .mx-icon-lined,
                        .mx-icon-filled {
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            width: $sidebar-icon-width;
                            height: $sidebar-icon-height;
                            padding: $spacing-small $spacing-medium;
                            border-radius: $border-radius-default;
                        }
                    }
                }
            }
        }

        // Topbar
        .region-topbar {
            padding: 0 $spacing-small;

            .toggle-btn {
                padding: 0;
                border-color: transparent;
                border-radius: 0;
                background: transparent;
                display: flex;
            }

            .mx-icon-filled,
            .mx-icon-lined {
                font-size: 20px;
            }
        }
    }

    // Topbar variant
    .layout-atlas-responsive-topbar {
        .region-topbar {
            padding: 0 $spacing-medium;
            @media (max-width: $screen-sm-max) {
                padding: 0 $spacing-small;
            }
        }
    }

    // Fix Safari issue of sidebar disappearing
    .profile-tablet {
        .mx-scrollcontainer:not(.mx-scrollcontainer-open) > .region-sidebar {
            overflow-y: hidden;

            .mx-scrollcontainer-wrapper {
                overflow: visible;
            }
        }
    }
}
